package com.uuuo.rxjavaandretrofit;

import com.uuuo.rxjavaandretrofit.entity.User;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Path;

/**
 * Created by JiaTao on 2018/9/10.
 * Email: 535318720@qq.com
 * Version: 1.0
 * Description:
 */
public interface UserService {
    @GET("user/getUser/{userID}")
    Observable<User> getUserInfo(@Path("userID") long userID);

    @FormUrlEncoded
    @POST("user/getUserByName")
    Observable<User> getUserByName(@Field("userName") String name);

    /**
     * Map的key作为表单的键
     */
    @FormUrlEncoded
    @POST("user/getUserByPwdAndAge")
    Observable<List<User>> getUserByPwdAndAge(@FieldMap Map<String, Object> map);

    @Multipart
    @POST("user/upload")
    Observable<User>  fileUpload(@Part("userName") RequestBody userName, @Part MultipartBody.Part file);
}
